package com.hugy.test.rabbitmq03;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

import com.hugy.test.basic.RabitMQConnection;
import com.hugy.test.basic.Constants;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

public class RoutingProducer {

	public static void main(String[] args) throws IOException, TimeoutException {
		Connection connection = RabitMQConnection.getConnection();
		Channel channel = connection.createChannel();
		// 声明交换机类型
		channel.exchangeDeclare(Constants.DIRECT_EXCHANGE_NAME, "direct",true);
		String routingKey = "2222";
		for (int i = 0; i < 10; i++) {
			String msg = "my_routing_destination_msg===" + routingKey +i;
			System.out.println("生产者发送消息:" + msg);
			channel.basicPublish(Constants.DIRECT_EXCHANGE_NAME, routingKey, null, msg.getBytes());
		}
		channel.close();
		connection.close();

	}

}
